using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameDataManager
{
    private static GameDataManager instance = new GameDataManager();
    public static GameDataManager Instance => instance;

    public MusicData musicData;

    private GameDataManager()
    {
        musicData = PlayerPrefsDataManager.Instance.LoadData(typeof(MusicData), "Music") as MusicData;
        
        if (!musicData.isNotFirst)
        {
            musicData = new MusicData();
            musicData.isNotFirst = true;
            musicData.musicValue = 1;
            musicData.soundValue = 1;
            musicData.isOpenMusic = true;
            musicData.isOpenSound = true;
            PlayerPrefsDataManager.Instance.SaveData(typeof(MusicData), "Music");
        }

    }

    public void OpenOrCloseMusic(bool isOpen)
    {
        musicData.isOpenMusic = isOpen;
        PlayerPrefsDataManager.Instance.SaveData(musicData,"Music");
    }
    public void OpenOrCloseSound(bool isOpen)
    {
        musicData.isOpenSound = isOpen;
        PlayerPrefsDataManager.Instance.SaveData(musicData,"Music");
    }

    public void ChangeMusicValue(float value)
    {
        musicData.musicValue = value;
        PlayerPrefsDataManager.Instance.SaveData(musicData,"Music");
    }

    public void ChangeSoundValue(float value)
    {
        musicData.soundValue = value;
        PlayerPrefsDataManager.Instance.SaveData(musicData,"Music");
    }
}